package validationTestSuite.tests
{
	import com.google.code.flexmetavalidator.metavalidation.MetaValidator;
	
	import org.flexunit.Assert;
	import org.flexunit.asserts.assertFalse;
	import org.flexunit.asserts.assertTrue;
	
	import validationTestSuite.tests.vo.NotNullObject;
	import validationTestSuite.tests.vo.NumericTestObject;
	
	public class NumericTestTest extends MetaValidatorTest
	{
		public function NumericTestTest()
		{
			super();
		}
		
		[Test]
		public function testNumberNoMinNoMax():void
		{
			var object : NumericTestObject;
			var testResult : Boolean;
			
			object = new NumericTestObject();
			object.varNumberNoMinNoMax = 10;
			testResult = validator.validate(object);
			assertTrue(testResult);
			
			object.varNumberNoMinNoMax = 0;
			testResult = validator.validate(object);
			assertTrue(testResult);

			object.varNumberNoMinNoMax = 99;
			testResult = validator.validate(object);
			assertTrue(testResult);

			object.varNumberNoMinNoMax = NaN;
			testResult = validator.validate(object);
			assertTrue(testResult);
			
			for each (var errStr : String in validator.errors) {trace(errStr)}
		}
		
		[Test]
		public function testNumberMin():void
		{
			var object : NumericTestObject;
			var testResult : Boolean;
			
			object = new NumericTestObject();
			object.varNumberMin = 10;
			testResult = validator.validate(object);
			assertTrue(testResult);
			
			object.varNumberMin = 0;
			testResult = validator.validate(object);
			assertFalse(testResult);
			
			object.varNumberMin = 99;
			testResult = validator.validate(object);
			assertTrue(testResult);
			
			object.varNumberMin = NaN;
			testResult = validator.validate(object);
			assertFalse(testResult);
			
			for each (var errStr : String in validator.errors) {trace(errStr)}
		}
		
		[Test]
		public function testNumberMax():void
		{
			var object : NumericTestObject;
			var testResult : Boolean;
			
			object = new NumericTestObject();
			object.varNumberMax = 10;
			testResult = validator.validate(object);
			assertTrue(testResult);
			
			object.varNumberMax = 0;
			testResult = validator.validate(object);
			assertTrue(testResult);
			
			object.varNumberMax = 99;
			testResult = validator.validate(object);
			assertFalse(testResult);
			
			object.varNumberMax = NaN;
			testResult = validator.validate(object);
			assertTrue(testResult);
			
			for each (var errStr : String in validator.errors) {trace(errStr)}
		}
		
		[Test]
		public function testNumberMinMax():void
		{
			var object : NumericTestObject;
			var testResult : Boolean;
			
			object = new NumericTestObject();
			object.varNumberMinMax = 10;
			testResult = validator.validate(object);
			assertTrue(testResult);
			
			object.varNumberMinMax = 0;
			testResult = validator.validate(object);
			assertFalse(testResult);
			
			object.varNumberMinMax = 99;
			testResult = validator.validate(object);
			assertFalse(testResult);
			
			object.varNumberMinMax = NaN;
			testResult = validator.validate(object);
			assertFalse(testResult);
			
			for each (var errStr : String in validator.errors) {trace(errStr)}
		}
		
			
	}
}